package com.luoxc.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

//@Component
//@Aspect
@Slf4j
public class TimeAspect {
    @Pointcut("execution(* com.luoxc.service.*.*(..))")
    public void pt(){};
    @Around("pt()")
    public Object Time(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();

        Object proceed = joinPoint.proceed(); // 调用原始方法运行

        long end = System.currentTimeMillis();

        log.info(joinPoint.getSignature() + " = 耗时: " + (end - start) + "ms");
        return proceed;
    }
}
